﻿Public Class GridFormExtPL

    Private _isReadOnlyGrid As Boolean = False

    ''' <summary>
    ''' Cette Propriété enlève la possibilité de Sauvé la grille
    ''' </summary>
    ''' <value></value>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Public Property IsReadOnlyGrid() As Boolean
        Get
            Return _isReadOnlyGrid
        End Get
        Set(ByVal value As Boolean)
            _isReadOnlyGrid = value
        End Set
    End Property

    Private Sub btnSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSave.Click
        Me.Cursor = Cursors.WaitCursor
        Me.GridExt1.SaveCommand()
        Me.Cursor = Cursors.Default
    End Sub

    Private Sub GridFormExt_FormClosed(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosedEventArgs) Handles Me.FormClosed
        'OutStandingIssue: Ca marche tu bazwell... - aleblanc 2011-05-30
        Me.GridExt1.GridControl1.Dispose()
        Me.GridExt1.GridView1.Dispose()
        Me.GridExt1.Dispose()
        Me.Dispose()
        GC.Collect()
        GC.WaitForPendingFinalizers()
    End Sub

    Private Sub GridFormExt_FormClosing(sender As Object, e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
        If (Me.GridExt1.DataSet.HasChanges) Then
            If Not MessageWindow.ShowMessage("Les données ont été modifiées. Voulez-vous vraiment quitter ?") = Windows.Forms.DialogResult.OK Then
                e.Cancel = True
            End If
        End If
    End Sub

    Private Sub GridFormExt_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If IsReadOnlyGrid Then
            MenuStrip1.Visible = False
            MenuStrip1.Enabled = False
        Else
            MenuStrip1.Visible = True
            MenuStrip1.Enabled = True
        End If
    End Sub
End Class